package cn.edu.scau.dormitory_management_system.util;

import cn.edu.scau.dormitory_management_system.constant.FilePath;
import cn.edu.scau.dormitory_management_system.exception.pojo.MyException;
import cn.edu.scau.dormitory_management_system.enums.ExceptionMsgEnum;

import java.io.Closeable;
import java.io.IOException;

/**
 * @author djc
 * @date 2021/8/8
 * @time 16:12
 */
public class IOUtil {
    public static void closeQuietly(final Closeable closeable) {
        try {
            if (closeable != null) {
                closeable.close();
            }
        } catch (final IOException ioe) {
            FileUtil.deleteFile(FilePath.TEMP_PATH);
            throw new MyException(ExceptionMsgEnum.CLOSE_IO_UTIL_ERROR);
        }
    }
}
